home *** CD-ROM | disk | FTP | other *** search
- set output error
- set display page 23
- set more 1
- #delimit ;
-
- di _n(13) in wh
- " ___ ____ ____ ____ ____ tm" _n
- " /__ / ____/ / ____/" _n
- "___/ / /___/ / /___/ QC.Kit: Programmed Extensions to Stata" _n
- "-----------------------------------------------------------------------"
- _n(2) ;
-
- di in gr
- "QC.Kit is a collection of programs written in Stata that provides some useful"
- _n
- "quality control commands. Although QC.Kit is written in Stata's programming"
- _n
- "language, you do not have to know anything about the programming language to"
- _n
- "use QC.Kit." _n ;
-
- di in gr
- "If your computer and monitor do not have graphics capabilities, there is no" _n
- "reason to run this tutorial. You can still use QC.Kit, but you will have to"
- _n
- "print the charts in order to see them. This tutorial assumes that you will"
- _n
- "be able to see the charts as we draw them. You can abort this tutorial by" _n
- "pressing "
- in wh "Break"
- in gr " (DOS users hold down "
- in wh "Ctrl" in gr " and press " in wh "Break"
- in gr ", Unix users hold down"
- _n
- in wh "Ctrl" in gr " and press " in wh "C"
- in gr "). On the next screen, we will verify that Stata thinks your"
- _n
- "computer has graphics capabilities." _n ;
-
- di in gr
- "If you are using a Sun under SunView, please "
- in wh "Break" in gr" out of this tutorial, type"
- _n
- "'" in wh "window define tut"
- in gr "', and then restart this tutorial. You don't have to do" _n
- "that, but results will be better if you do. (You may have already done this"
- _n
- "when you ran the graphics tutorial. If so, you don't need to do it again.)"
- _n ;
-
- #delimit cr
- mac def path
- capture run nullfile.tut
- if _rc {
- mac def path "\stata\"
- capture run %path`nullfile.tut
- if _rc {
- mac def path "/usr/stata/"
- capture run %path`nullfile.tut
- if _rc {
- #delimit ;
- di in red
- "I cannot find the other tutorial files. I have looked in the current" _n
- "directory and in \stata (DOS) or /usr/stata (Unix). Is Stata installed" _n
- "correctly?" _n(2)
- "In any case, I cannot run the tutorial." ;
- #delimit cr
- exit
- }
- }
- }
- macro define F5 "do %path`contents.tut;"
- macro define F6 "do %path`ourdata.tut;"
- #delimit ;
- set more 0 ; more ; set more 1 ;
-
-
- di _n(4) in wh
- "More preliminary" _n
- "----------------" _n(2)
- ". query" ;
- noisily query ;
-
- di in gr _n
- "If the above display indicates that "
- in wh "graphics" in gr " are " in wh "off"
- in gr ", Stata does not think" _n
- "your computer and monitor have graphics capabilities, so you may as well" _n
- in wh "Break" in gr " out of this tutorial." _n ;
- set more 0 ; more ; set more 1 ;
-
- drop _all ;
- label drop _all ;
- program drop _all ;
- macro define F6 "do %path`qckit.tut;" ;
-
- di _n(10) in wh
- "Loading QC.Kit" _n
- "--------------" _n ;
-
- di _n(2) in wh _dup(79) "-" _n in gr
- "Before you can use QC.Kit, you must load it:" _n
- in wh _dup(79) "-" _n(6)
- ". run %path`QC.Kit" ;
- run %path`QC.Kit ;
- di _n(2) ; set more 0 ; more ; set more 1 ;
-
- di _n(4) in wh
- "Overview" _n
- "--------" _n ;
-
- di in gr
- "QC.Kit provides three new commands:" _n(2)
- _col(8) in wh "cchart" in gr _col(20)
- "make a c-Chart" _n
- _col(8) in wh "pchart" in gr _col(20)
- "make a p-Chart" _n
- _col(8) in wh "plotebar" in gr _col(20) "make an error-bar chart" _n
- ;
-
- di in gr
- "In most quality-control applications, you will want to tailor Stata to your"
- _n
- "environment. You should therefore view QC.Kit not as an exhaustive list of"
- _n
- "Stata's capabilities, but as examples of the kinds of things you can do in" _n
- "Stata. Since QC.Kit is written in Stata's programming language and is just" _n
- "an ASCII file, you can modify the commands to suit your application and you"
- _n
- "can add new ones." _n(2)
- "Right now, Stata is secretly loading some data which we will use to "
- "demonstrate" _n
- "QC.Kit. We will use data from the revised edition of "
- in ye "Quality Control and In" in gr "-" ;
- di in ye
- "dustrial Statistics" in gr
- " by Acheson J. Duncan. We have data on the number of rail-"
- _n
- "way frames rejected from a random sample of 50 frames from each day's output."
- _n
- "These data cover the first 28 days in May." _n ;
-
- input day rejects ;
- 1 4 ;
- 2 9 ;
- 3 10;
- 4 11;
- 5 13;
- 6 30;
- 7 26;
- 8 13;
- 9 8 ;
- 10 23;
- 11 34;
- 12 25;
- 13 18;
- 14 12;
- 15 4;
- 16 3;
- 17 11;
- 18 8 ;
- 19 14;
- 20 21;
- 21 25;
- 22 18;
- 23 10;
- 24 8;
- 25 18;
- 26 19;
- 27 4;
- 28 8;
- end;
- gen ssize=50 ;
- label data "Number rejected by day" ;
- label variable rejects "Number rejected" ;
- label var ssize "Sample size" ;
- label var day "Day" ;
- di _n in wh ". describe" ;
- set more 0 ; more ; set more 1 ;
- noisily describe ;
- di _n in wh ". list in 1/7" ;
- noisily list in 1/7 ;
- di _n in wh ". summarize rejects, detail" ;
- set more 0 ; more ; set more 1 ;
- noisily summarize rejects, detail ;
- di _n in wh _dup(79) "-" _n in wh
- "pchart" in gr " will draw the p-Chart:" _n
- in wh _dup(79) "-" _n(2)
- ". pchart rejects day ssize, ylabel xlabel" ;
- set more 0 ; more ;
- pchart rejects day ssize, ylabel xlabel ;
- set more 1 ;
- replace ssize=2*(_N+mod(_n,9)) ;
-
- di _n(2) in wh _dup(79) "-" _n in gr
- "The third variable in the "
- in wh "pchart" in gr " command specifies the sample size and "
- in wh "pchart" in gr _n
- "does not require that the sample sizes be the same across all days. This tu-"
- _n
- "torial has silently changed the data, making the sample sizes vary:" _n
- in wh _dup(79) "-" _n(2)
- ". list in 1/6" ;
- noisily list in 1/6 ;
- di _n in wh ". pchart rejects day ssize, ylabel xlabel" ;
- set more 0 ; more ;
- pchart rejects day ssize, ylabel xlabel ;
- set more 1 ;
-
- di _n(6) in wh _dup(79) "-" _n in gr
- "The syntax of the " in wh "pchart" in gr " command is" _n(2)
- _col(8) in wh "pchart " in gr "reject_var unit_var smplsize_var ["
- in wh ", stabilized " in gr "graph_options]" _n(2)
- "where the three variables record the number of items rejected, the unit that"
- _n
- "produced the sample, and the size of the sample that was inspected. We have"
- _n
- "used the date of production as the unit_var, although the unit_var could just"
- _n
- "as well specify separate production units on the same day. "
- in wh "pchart" in gr " allows all" _n
- "the options of " in wh "graph" in gr "'s " in wh "twoway"
- in gr " style, and we have specified "
- in wh "ylabel" in gr " and " in wh "xlabel" in gr "." _n
- "The "
- in wh "stabilized" in gr
- " option draws stabilized p-Charts when sample sizes vary:" _n
- in wh _dup(79) "-" _n(4)
- ". pchart rejects day ssize, xlabel ylabel stabilized title(May Production)"
- ;
- set more 0 ; more ;
- pchart rejects day ssize, xlabel ylabel stabilized title(May Production) ;
- set more 1 ;
- drop _all;
- input sample defects;
- 1 77;
- 2 64;
- 3 75;
- 4 93;
- 5 45;
- 6 61;
- 7 49;
- 8 65;
- 9 45;
- 10 77;
- 11 59;
- 12 54;
- 13 41;
- 14 87;
- 15 40;
- 16 22;
- 17 92;
- 18 89;
- 19 55;
- 20 25;
- 21 54;
- 22 22;
- 23 49;
- 24 33;
- 25 20;
- end;
- label data "Number of defects in 25 samples";
- label variable sample "Subassembly number";
- label variable defects "Number of defects";
-
- di _n(2) in wh _dup(79) "-" _n in gr
- "QC.Kit can also draw c-Charts. We'll use a slightly different data set to il-"
- _n
- "lustrate this, which this tutorial is now quietly loading. These data record"
- _n
- "the number of defects per sample in 25 samples of 5 radio sets each:" _n
- in wh _dup(79) "-" _n(2)
- ". describe" ;
- noisily describe ;
- di _n in wh ". list in 1/5" ;
- noisily list in 1/5 ;
- set more 0 ; more ; set more 1 ;
-
- di _n(2) in wh _dup(79) "-" _n in gr
- "The syntax of the "
- in wh "cchart" in gr " command is much like that of "
- in wh "pchart" in gr ":" _n(2)
- _col(8) in wh "cchart"
- in gr " defects_var unit_var [" in wh ", " in gr "graph_options]" _n(2)
- "In addition, all of Stata's Kit commands -- Stat.Kit, Graph.Kit, Data.Kit, and"
- _n
- "QC.Kit -- show the syntax of the command when it is typed without arguments:"
- _n
- in wh _dup(79) "-" _n(2)
- ". cchart" ;
- cchart ;
- di _n in wh
- ". cchart defects sample, ylabel xlabel title(c-Chart for Radio Subassemblies)" ;
- set more 0 ; more ;
- cchart defects sample, ylabel xlabel title(c-Chart for Radio Subassemblies) ;
- set more 1 ;
- drop _all ;
- input date mean std;
- 8. 192.21944 3.9370465;
- 9. 192.64444 2.833564;
- 10. 192.36667 4.5780769;
- 13. 194.7625 3.2508827;
- 14. 192.68889 2.8898289;
- 15. 195.01818 1.7303573;
- 16. 193.40278 2.6157595;
- end;
-
- di _n(2) in wh _dup(79) "-" _n in gr
- "You can produce any kind of control chart with Stata and you can use Stata to"
- _n
- "produce other charts to help design and administer acceptance sampling plans"
- _n
- "or other quantitative chores." _n(2)
- "The " in wh "plotebar" in gr
- " command generates an error-bar chart. This tutorial has once" _n
- "again secretly changed the data set so we could demonstrate this command:" _n
- in wh _dup(79) "-" _n(5)
- ". list" ;
- noisily list ;
- di _n in wh
- ". plotebar" ;
- set more 0 ; more ; set more 1 ;
- plotebar ;
- di _n(2) in wh
- ". plotebar mean std date, yline(195) title(Weight Variation) ylabel xlabel" ;
- set more 0 ; more ;
- plotebar mean std date, title(Weight variation) yline(195) ylabel xlabel
- border tlab rlab ;
- set more 1 ;
-
- drop _all ;
- input unit sum top bot;
- 1 -.367 . . ;
- 2 -.649 . . ;
- 3 -.75 . . ;
- 4 -.617 . . ;
- 5 -.797 . . ;
- 6 -.672 . . ;
- 7 -.259 . . ;
- 8 -.015 . . ;
- 9 .245 . . ;
- 10 .583 . . ;
- 11 .1 . . ;
- 12 .342 . . ;
- 13 -.148 . . ;
- 14 -.587 . . ;
- 15 -.472 . . ;
- 16 -.496 .792 -.792 ;
- 17 -.659 .72 -.72 ;
- 18 -.319 .648 -.648 ;
- 19 -.576 .576 -.576 ;
- 20 -.684 .504 -.504 ;
- 21 -.766 .432 -.432 ;
- 22 -.224 .36 -.36 ;
- 23 . .288 -.288 ;
- 24 . .216 -.216 ;
- 25 . .144 -.144 ;
- 26 . .072 -.072 ;
- 27 . 0. 0. ;
- 28 . . . ;
- 29 . . . ;
- 30 . . . ;
- end ;
- label variable unit "Sample number" ;
- label variable sum "Cum. deviations" ;
- label variable top " " ;
- label variable bot " " ;
-
- di _n(2) in wh _dup(79) "-" _n in gr
- "Finally, let's produce a cusum chart. This time, rather than using a QC.Kit"
- _n
- "command, we'll just use Stata's "
- in wh "graph" in gr " command. We've already performed some"
- _n
- "calculations using Stata so all we need to do is align our statistical data"
- _n
- "in a meaningful way to produce the cusum chart. The main point is that Stata"
- _n
- "is often flexible enough to produce exactly the chart you need even though no"
- _n
- "Stata command explicitly performs the task:" _n
- in wh _dup(79) "-" _n(4)
- ". describe" ;
- noisily describe ;
- di _n in wh
- ". graph sum top bot unit, yline(0) ylabel xlabel c(.ll) s(oii)" ;
- set more 0 ; more ;
- format sum %8.1f ;
- graph sum top bot unit, yline(0) ylabel xlabel c(.ll) s(oii) pen(244) ;
- set more 1 ;
-
-
- di _n(2) in wh _dup(79) "-" _n in gr
- "Remember, these are only a small sample of the charts you can produce with"
- _n
- "Stata. If you are seriously interested in automating a quality-control ap-"
- _n
- "plication, you will want to learn about Stata's programming language. You" _n
- "can write programs in Stata that, at the touch of literally a single key," _n
- "will read data from disk, write reports, and draw graphs." _n(2)
- "For simple quality control applications, QC.Kit is probably enough. QC.Kit,"
- _n
- "however, is written in Stata's programming language and you can modify it." _n
- "All of Stata's kits provide excellent examples of how to use Stata's program-"
- _n
- "ming language." _n
- in wh _dup(79) "-" _n(10) ;
- drop _all ;
- label drop _all ;
- macro define F6 "do %path`ourdata.tut;" ;
- set more 0 ; more ; set more 1 ;
-
- di _n(4) in white
- "Demonstration ends" _n
- "------------------" _n ;
-
-
- di in green
- "That concludes our short demonstration, but there's much more. We now return"
- _n
- "control to you. Some suggestions:" _n ;
-
- di in green
- "If you ..." _col(34) "Then we will show you ..." _n
- " Press " in white "F5" in green _col(38) "a table of tutorial contents" _n
- " Press " in white "F6" in green _col(38) "the next tutorial, "
- in white "ourdata.tut" _n ;
-
- run %path`tobuy.tut ;